//
//  DTKMapBundleDemoJSAPI.m
//  DTKMapBundleBundle
//
//  Created by ddev CLI Tools on 2021/3/24.
//

#import "DTKMapBundleDemoJSAPI.h"
#import <AMapLocationKit/AMapLocationKit.h>
#import "LocationUtil.h"
#import "DTKMapBundle.h"
#import "SearchMapViewController.h"

@implementation DTKMapBundleDemoJSAPI

+ (NSArray<NSString *> *)apiNameList {
    return @[@"lanling.location"];
}

- (void)handleRequest:(id<DTKExternalAPIRequest>)request
          withContext:(id<DTKExternalJSAPIContext>)context
             callback:(DTKExternalAPICallback)callback {
    
//    SearchMapViewController* shareVC = [[SearchMapViewController alloc] initWithBlock:^(id<DGLBSLocation>  _Nullable location) {
//
//    }];
//    shareVC.modalPresentationStyle = UIModalPresentationFullScreen;
//    [[[DTKMapBundle services] uiHierachyService].currentTopViewController presentViewController:shareVC animated:YES completion:nil];
    
//    AMapLocationManager *locationManager = [LocationUtil shareInstance].locationManager;
//    locationManager.distanceFilter = kCLDistanceFilterNone;
//    locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters;
//    locationManager.pausesLocationUpdatesAutomatically = NO;
//    [locationManager requestLocationWithReGeocode: YES completionBlock:^(CLLocation *location, AMapLocationReGeocode *regeocode, NSError *error) {
//        if (error) {
//            NSDictionary *error = @{
//                @"code": @"501",
//                @"message": @"get location failed"
//            };
//            callback(error);
//        } else {
//            [NSNumber numberWithDouble:200];
//            NSDictionary *result = @{
//                @"lat": [NSNumber numberWithDouble:location.coordinate.latitude],
//                @"lon": [NSNumber numberWithDouble:location.coordinate.longitude],
//            };
//            callback(result);
//        }
//    }];
    
}

@end
